import { baseRequestClient, requestClient } from '#/api/request';

export namespace SalesNotice {
  export interface Params {
    attr1: null;
  }
  export interface Row {
    [x: string]: any;
    [x: string]: any;
    [x: string]: any;
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: Date;
    remark: string;
    params: Params;
    noticeId: number;
    noticeCode: string;
    noticeName: string;
    soCode: string;
    clientId: number;
    clientCode: string;
    clientName: string;
    clientNick: string;
    salesDate: Date;
    recipient: string;
    tel: string;
    address: string;
    status: string;
    attr2: null;
    attr3: number;
    attr4: number;
    attr1: boolean | null | string;
  }
  export interface GetListParams {
    pageNum: number;
    pageSize: number;
    noticeId?: string;
  }
  export interface GetListReturn {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
}

// 获取列表
export const getSalesNoticeTableList = (params: SalesNotice.GetListParams) =>
  requestClient.get<SalesNotice.GetListReturn>('/mes/wm/salesnotice/list', {
    params,
  });
// 增加发货通知
export const addSalesNotice = (data: SalesNotice.Row) =>
  requestClient.post<SalesNotice.GetListReturn>('/mes/wm/salesnotice', data);

// 删除发货通知
export const deleteSalesNotice = (id: string) =>
  requestClient.delete<SalesNotice.GetListReturn>(`/mes/wm/salesnotice/${id}`);

// 修改发货通知
export const updateSalesNotice = (data: SalesNotice.Row) =>
  requestClient.put<SalesNotice.GetListReturn>('/mes/wm/salesnotice', data);

export const getSalesNoticeCode = () =>
  baseRequestClient.get<any>('/system/autocode/get/WM_SALES_NOTICE_CODE');
